package org.jsola.hr.helper;

import org.jsola.hr.dto.TransferAccountsZfbSafetyBatchAddDTO;
import org.jsola.hr.dto.TransferAccountsZfbSafetyBatchUpdateDTO;
import org.jsola.hr.entity.TransferAccountsZfbSafetyBatchDO;
import org.jsola.hr.query.TransferAccountsZfbSafetyBatchQuery;
import org.jsola.hr.service.ITransferAccountsZfbSafetyBatchService;
import org.jsola.hr.vo.TransferAccountsZfbSafetyBatchVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 转账批次(支付宝安全发)
 *
 * @author zhr
 */
@Component
public class TransferAccountsZfbSafetyBatchTestHelper extends BaseTestHelper {
    
    @Autowired
    private ITransferAccountsZfbSafetyBatchService transferAccountsZfbSafetyBatchService;

    /**
     * 生成add测试数据
     * @return TransferAccountsZfbSafetyBatchAddDTO
     */
    public TransferAccountsZfbSafetyBatchAddDTO getTransferAccountsZfbSafetyBatchAddDTO(){
        TransferAccountsZfbSafetyBatchAddDTO transferAccountsZfbSafetyBatchAddDTO = new TransferAccountsZfbSafetyBatchAddDTO();
        transferAccountsZfbSafetyBatchAddDTO.setBatchId(getRandomValue("varchar",32));
        transferAccountsZfbSafetyBatchAddDTO.setOrderTitle(getRandomValue("varchar",64));
        transferAccountsZfbSafetyBatchAddDTO.setRemark(getRandomValue("varchar",256));
        transferAccountsZfbSafetyBatchAddDTO.setBatchTransId(getRandomValue("varchar",100));
        transferAccountsZfbSafetyBatchAddDTO.setProductCode(getRandomValue("varchar",64));
        transferAccountsZfbSafetyBatchAddDTO.setBizScene(getRandomValue("varchar",64));
        transferAccountsZfbSafetyBatchAddDTO.setPayerExtInfo(getRandomValue("varchar",256));
        transferAccountsZfbSafetyBatchAddDTO.setPayerBookId(getRandomValue("varchar",20));
        transferAccountsZfbSafetyBatchAddDTO.setPayerUserId(getRandomValue("varchar",64));
        transferAccountsZfbSafetyBatchAddDTO.setTotalItemCount(getRandomValue("varchar",5));
        transferAccountsZfbSafetyBatchAddDTO.setSuccessCount(getRandomValue("varchar",5));
        transferAccountsZfbSafetyBatchAddDTO.setFailCount(getRandomValue("varchar",5));
        transferAccountsZfbSafetyBatchAddDTO.setTotalAmount(getRandomValue("varchar",13));
        transferAccountsZfbSafetyBatchAddDTO.setSuccessAmount(getRandomValue("varchar",13));
        transferAccountsZfbSafetyBatchAddDTO.setFailAmount(getRandomValue("varchar",13));
        transferAccountsZfbSafetyBatchAddDTO.setBatchStatus(getRandomValue("varchar",13));
        return transferAccountsZfbSafetyBatchAddDTO;
    }


    /**
     * 生成update测试数据
     * @return TransferAccountsZfbSafetyBatchUpdateDTO
     */
    public TransferAccountsZfbSafetyBatchUpdateDTO getTransferAccountsZfbSafetyBatchUpdateDTO(TransferAccountsZfbSafetyBatchVO transferAccountsZfbSafetyBatchVO){
        return transferAccountsZfbSafetyBatchService.selectDOById(transferAccountsZfbSafetyBatchVO.getId(), SITE_ID).to(TransferAccountsZfbSafetyBatchUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return TransferAccountsZfbSafetyBatchQuery
     */
    public TransferAccountsZfbSafetyBatchQuery getTransferAccountsZfbSafetyBatchQuery() {
        TransferAccountsZfbSafetyBatchQuery transferAccountsZfbSafetyBatchQuery = new TransferAccountsZfbSafetyBatchQuery();
        List<TransferAccountsZfbSafetyBatchDO> transferAccountsZfbSafetyBatchDOList = transferAccountsZfbSafetyBatchService.list(new TransferAccountsZfbSafetyBatchDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(transferAccountsZfbSafetyBatchDOList)) {
            TransferAccountsZfbSafetyBatchDO transferAccountsZfbSafetyBatchDO = transferAccountsZfbSafetyBatchDOList.get(0);
            transferAccountsZfbSafetyBatchQuery = transferAccountsZfbSafetyBatchDO.to(TransferAccountsZfbSafetyBatchQuery.class);
        }
        return transferAccountsZfbSafetyBatchQuery;
    }

    /**
     * 保存示例
     * @return TransferAccountsZfbSafetyBatchVO
     */
    public TransferAccountsZfbSafetyBatchVO saveTransferAccountsZfbSafetyBatchExample(){
        TransferAccountsZfbSafetyBatchAddDTO addDTO = this.getTransferAccountsZfbSafetyBatchAddDTO();
        TransferAccountsZfbSafetyBatchVO transferAccountsZfbSafetyBatchVO = transferAccountsZfbSafetyBatchService.save(addDTO,buildTokenUser());
        return transferAccountsZfbSafetyBatchVO;
    }


}

